home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * DUALMON.C - Nice little routine to allow output to a monochrome monitor
- * setup as a secondary monitor.
- *
- * DUALMON.C was surgically extracted from BUGOUT (without pain killers) by:
- *
- * Mark R. Holbrook
- * 805-964-4471
- * 76436,1224 Compuserve
- * 76436.1224@compuserve.com
- *
- * You may use and distribute this program freely. In fact, you can even
- * modify this program at any time if you have an editor. Hell for all that
- * matters, you can even compile this program if you have a compiler. If we
- * are going to go this far, you can even delete it or convert it to COBOL!
- * All I ask is that my name be kept with it and if you
- * make any neat changes to it. Please update the version number and
- * send a copy back to me!
- *
- * If you really insist on sending me money for this.. this.. thing, well
- * I guess I could make an exception... Let's discuss it!
- *
- * Revision history: (sadly typical)
- * -----------------
- *
- * 0.40 First compile and run. Compile went ok. The run is a totally
- * different story!
- *
- */
-
- #define DUALVERSION 0.50
-
- /*
- * Include our own include file. Define us as the main routine
- */
- #define DUALMAIN
- #include <dualmon.h>
-
- /*
- * Other include files we need
- */
- #include <ctype.h>
- #include <mem.h>
- #include <stdarg.h>
- #include <stdlib.h>
-
- /*
- * ScrollMono() - Scroll the entire contents of the monochrome
- * display up 1 line. (or at times directly into the core memory
- * of the Naval Observatory Atomic clock computer thereby completely
- * changing time and history as we know it.)
- *
- * What if you don't have a monochrome adapter? Well on some machines
- * this code is still harmless because whatever garbage exists at the
- * address of the monochome adapter is moved around a bit and composted
- * providing a rich but smelly environment for small living things. On other
- * machines this address maps directly into the Hollywood Hills Sanitation
- * department valve control center. During initial testing we (quite
- * accidentally) caused Madonna's toilet to backup and overflow while she
- * was using it. (The court date has been set but a jury has not been
- * selected since finding a jury of our peers is quite difficult).
- */
- void ScrollMono( unsigned int Lines )
- {
- /* Vars */
- register int i;
- register int j;
-
- /* Scroll up as many lines as they desire */
- for( i = 0; i < Lines; i++ )
- {
- /* Move the existing screen contents up 1 line */
- movedata( 0xb000, 80*2, 0xb000, 0, (24*80*2) );
-
- /* Blank fill the bottom line */
- for( j = 0; j < 80; j++ )
- *(Mono+(24*80)+j) = 0x0720;
- }
- } /* ScrollMono() */
-
-
- /*
- * ClearMono() - Clear the entire monochrome display.
- * You can call it as often as you like to clean
- * up the appearance of your debug output.
- */
- void ClearMono( void )
- {
- _fmemset( (void far *)Mono, 0x0720, (80*25*2) );
- } /* ClearMono() */
-
-
- /*
- * PrintToMono() - Output directly to the monochrome display.
- * You can specify a row and col to print to or you can specify a
- * row == 0 to get a bottom line write then scroll up effect.
- * The function supports multiple arguments (like printf).
- */
- void PrintToMono( unsigned int Row,
- unsigned int Col,
- unsigned int Att,
- char *Fmt, ... )
- {
- /* Vars */
- register int i;
- int Len;
- char *Msg;
- char buf[256];
- va_list arg;
-
- /* Convert the arguments into the buffer */
- va_start( arg, Fmt );
- vsprintf( buf, Fmt, arg );
- va_end( arg );
-
- /* Point to the buffer and get it's length */
- Msg = buf;
- Len = strlen( Msg );
-
- /* Set a default attribute */
- if( Att == 0 )
- Att = 0x07;
-
- /*
- * If the row is 0 then we scroll the mono display
- * up a line and print to the bottom of the display
- */
- if( Row == 0 )
- {
- /* Scroll up one */
- ScrollMono( 1 );
-
- /* Print to the bottom line */
- for( i = 0; i < Len && i < 80; i++ )
- *(Mono+(24*80)+i) = (Att << 8) | *(Msg+i);
- }
- else
- {
- /*
- * Make row & col zero based - this is stupid! Why didn't write the
- * code so I wouldn't have to do this. I hate making things zero based!
- * It just seemed like having 0 scroll up a line was so logical... Well
- * you can change it if you like!
- */
- Row -= 1;
- if( Col )
- Col -= 1;
-
- /* Print to the desired row & col */
- for( i = 0; i < Len && i < 80; i++ )
- *(Mono+(Row*80)+Col+i) = (Att << 8) | *(Msg+i);
- }
- } /* PrintToMono() */
-
-